package com.woniuxy02;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Test01 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str="abc中文字符";
        //将字符串转成对应的字节编码
        System.out.println(Arrays.toString(str.getBytes()));
        System.out.println(Arrays.toString(str.getBytes("utf-8")));
        System.out.println(Arrays.toString(str.getBytes("gbk")));

        String s1="aaa中文";
        //编码  utf-8
        byte[] bytes = s1.getBytes("gbk");
        //解码  utf-8
        System.out.println(new String(bytes,"gbk"));
    }
}
